package com.ysd.lis.service.lab.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ysd.common.Result;
import com.ysd.lis.entity.lab.LabRptdetailBac;
import com.ysd.lis.mapper.lab.LabRptdetailBacMapper;
import com.ysd.lis.service.lab.LabRptdetailBacService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author cfz
 * @since 2024-03-26
 */
@Service
public class LabRptdetailBacServiceImpl extends ServiceImpl<LabRptdetailBacMapper, LabRptdetailBac> implements LabRptdetailBacService {

    @Autowired
    LabRptdetailBacMapper labRptdetailBacMapper;

    @Override
    public Result findLabRptdetailBacList(LabRptdetailBac labRptdetailBac) {
        MPJLambdaWrapper<LabRptdetailBac> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.eq(LabRptdetailBac::getDelFlag, 0);
        List<LabRptdetailBac> list = labRptdetailBacMapper.selectList(queryWrapper);
        return Result.succ(1, "请求成功", list);
    }

    @Override
    public Result addLabRptdetailBac(LabRptdetailBac labRptdetailBac) {
        int i = labRptdetailBacMapper.insert(labRptdetailBac);
        if (i > 0) {
            return Result.succ(1, "新增成功", labRptdetailBac);
        }
        return Result.fail("新增失败");
    }

    @Override
    public Result deleteLabRptdetailBac(LabRptdetailBac labRptdetailBac) {
        labRptdetailBac.setDelFlag(1);
        int i = labRptdetailBacMapper.updateById(labRptdetailBac);
        if (i > 0) {
            return Result.succ(1, "删除成功", labRptdetailBac);
        }
        return Result.fail("删除失败");
    }

    @Override
    public Result updateLabRptdetailBac(LabRptdetailBac labRptdetailBac) {
        int i = labRptdetailBacMapper.updateById(labRptdetailBac);
        if (i > 0) {
            return Result.succ(1, "更新成功", labRptdetailBac);
        }
        return Result.fail("更新失败");
    }
}
